import 'package:boss/models/commission.dart';
import 'package:boss/ui/page/commission/page/commissionDetail/provider/commission_detail_provider.dart';
import 'package:boss/ui/page/commission/page/commissionDetail/widget/commission_detail_browser.dart';
import 'package:boss/ui/widget/alert/alert.dart';
import 'package:boss/ui/widget/back_confirmation.dart';
import 'package:boss/ui/widget/center_title_app_bar.dart';
import 'package:flutter/material.dart';
import 'package:hi_common/hi_common.dart';
import 'package:provider/provider.dart';
import 'package:router/annotation.dart';

@RouterConfig(CommissionDetailPage.pageName)
class CommissionDetailPage extends StatefulWidget {
  static const pageName = '/commissionDetailPage';

  @Autowired()
  final int commissionId;

  @Autowired()
  final String commissionStatus;

  @Autowired()
  final Commission commission;

  const CommissionDetailPage({
    this.commissionId,
    this.commission,
    this.commissionStatus,
    Key key,
  }) : super(key: key);

  @override
  _CommissionDetailPageState createState() => _CommissionDetailPageState('菜品提成');
}

class _CommissionDetailPageState extends BaseState<CommissionDetailPage> {
  _CommissionDetailPageState(String pageName) : super(pageName);

  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (ctx) => CommissionDetailProvider(widget.commission, widget.commissionId, widget.commissionStatus),
      child: BackConfirmation(
        backConfirmationText: '提成还未完成确认返回么？',
        child: Scaffold(
          appBar: CenterTitleAppBar(
            title: '提成设置',
            backConfirmationText: '提成还未完成确认返回么？',
          ),
          body: CommissionDetailBrowser(),
        ),
      ),
    );
  }
}
